//
//  IT_Macro.h
//  InTube
//
//  Created by Seven on 2019/10/28.
//  Copyright © 2019 Seven. All rights reserved.
//

#import <Foundation/Foundation.h>

#ifndef IT_Macro_h
#define IT_Macro_h


//Screen
//尺寸-------------------------------
#define GDeviceWidth [UIScreen mainScreen].bounds.size.width
#define GDeviceHeight [UIScreen mainScreen].bounds.size.height

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)

#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))

#define IPHONE_X \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneX);})


//image
#define IMAGE(name, type) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:name ofType:type]]
#define ImageNamed(A) [UIImage imageNamed:A]

//属性
#define IT_PROPERTY(...) @property(nonatomic, ##__VA_ARGS__)
#define IT_PROPERTY_STRONG IT_PROPERTY(strong)
#define IT_PROPERTY_ASSIGN IT_PROPERTY(assign)
#define IT_PROPERTY_WEAK   IT_PROPERTY(weak)
#define IT_PROPERTY_COPY   IT_PROPERTY(copy)
#define IT_NULLABLE  _Nullable

#define WEAKSELF @weakify(self);
#define STRONGSELF @strongify(self);
//适配屏幕的CGFloat 按照plus的比例适配高度
#define FitScreen_H(float)  round((CGFloat)(float * (SCREEN_H / 667.0)))
#define FitScreen_W(float)  round((CGFloat)(float * (SCREEN_W / 375.0)))

//Log
#if DEBUG

#define NSLog( s, ... ) NSLog( @"<%@:(%d)> %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [[NSString stringWithFormat:(s), ##__VA_ARGS__] unicodeToChinese] )
#else

#define NSLog( s, ... )

#endif


//adjustsScrollViewInsets
#define  adjustsScrollViewInsets(scrollView)\
do {\
_Pragma("clang diagnostic push")\
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"")\
if ([scrollView respondsToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
NSMethodSignature *signature = [UIScrollView instanceMethodSignatureForSelector:@selector(setContentInsetAdjustmentBehavior:)];\
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];\
NSInteger argument = 2;\
invocation.target = scrollView;\
invocation.selector = @selector(setContentInsetAdjustmentBehavior:);\
[invocation setArgument:&argument atIndex:2];\
[invocation retainArguments];\
[invocation invoke];\
}\
_Pragma("clang diagnostic pop")\
} while (0)


//Block
typedef void(^TapBlock)(id sender);
typedef void(^CompleteBlock)(id sender);


#define HomeCellTopHeight 81
#define HomeCellInteractionHeight 90
#define HomeCellBottomHeight (HomeCellInteractionHeight + 20)
#define HomeCellImageHeight (GDeviceWidth/HomeVideoAspect)

#define HomeVideoAspect (16.0/9.0)

#define InteractionLinkImageAspect 1.0

#define HomeCellHeight (HomeCellTopHeight + HomeCellImageHeight + HomeCellInteractionHeight + HomeCellBottomHeight)

#define HomeListViewHeight (GDeviceHeight - [UIDevice safeAreaTopHeight] - [UIDevice safeAreaBottomHeight])

#define ITCommentItemSpeed 70.0

#define NSStringDrawingDefault (NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading)
#define NSLineBreakModeDefault (NSLineBreakByWordWrapping)

#define Version_Code 20000

#define InviteChannelKey @"InviteChannelKey"
#define InviteCodeKey @"InviteCodeKey"
#define InviteCodeUploadKey @"InviteCodeUploadKey"

#define NotificationUserLoginSuccess @"NotificationLoginSuccess"
#define NotificationUserActivation @"NotificationUserActivation"


#define DidShowedVideoGuide @"DidShowedVideoGuide"
#define DidFinishedVideoGuide @"DidFinishedVideoGuide"



#define DidShowedDefaultVideo @"DidShowedDefaultVideo"
#define DidFinishedDefaultVideo @"DidFinishedDefaultVideo"


#define PauseHomePlayer @"PauseHomePlayer"
#define ResumeHomePlayer @"ResumeHomePlayer"


#define ITForYouGuideKey @"ITForYouGuideKey"
#define NotificationShowForYouGuide @"NotificationShowForYouGuide"

#define DICT_WEB_PRIVACY @"DICT_WEB_PRIVACY"
#endif /* IT_Macro_h */
